<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/11/2
 * Time: 10:36
 */
namespace app\v1\controller;

use think\Request;

class Fightgroups extends \think\Controller
{
    private function getFightgroups()
    {
        return model("Fightgroups");
    }

    /*
     * 商户方法
     * */
    public function fightgroups(Request $request)
    {

        if ($request->isPost()) {//创建

            return json_encode($this->getFightgroups()->add($request->param()));

        } else if ($request->isGet()) {//获取

            if (is_numeric($request->param("status"))) {
                //获取指定类型的数据
                return json_encode($this->getFightgroups()->getFGByStatus($request->param()));
            } else {
                return json_encode($this->getFightgroups()->getFG($request->param("_id")));
            }

        } else if ($request->isDelete()) {//删除

            return json_encode($this->getFightgroups()->del($request->param("_id")));

        } else if ($request->isPut()) {//更新写入
            return json_encode($this->getFightgroups()->updateFG($request->param()));
        }
    }
    public function fightgroups2(Request $request){
        if($request->isGet()) {
            return json_encode($this->getFightgroups()->getFG($request->param()));
        }else{
            return json_encode($this->getFightgroups()->updateFG($request->param()));
        }
    }

    public function test()
    {
         var_dump($this->getFightgroups()->getFG(['goodId' => "5a1b7925b356b751b4003ee4"])) ;
    }


}